home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / splain.z / splain
Text File  |  1998-10-30  |  8KB  |  265 lines

  1.  
  2.  
  3.  
  4. SSSSPPPPLLLLAAAAIIIINNNN((((1111))))                                                            SSSSPPPPLLLLAAAAIIIINNNN((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      diagnostics - Perl compiler pragma to force verbose warning diagnostics
  10.  
  11.      splain - standalone program to do the same thing
  12.  
  13. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  14.      As a pragma:
  15.  
  16.          use diagnostics;
  17.          use diagnostics -verbose;
  18.  
  19.          enable  diagnostics;
  20.          disable diagnostics;
  21.  
  22.      Aa a program:
  23.  
  24.          perl program 2>diag.out
  25.          splain [-v] [-p] diag.out
  26.  
  27.  
  28. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  29.      TTTThhhheeee ddddiiiiaaaaggggnnnnoooossssttttiiiiccccssss Pragma
  30.  
  31.      This module extends the terse diagnostics normally emitted by both the
  32.      perl compiler and the perl interpeter, augmenting them with the more
  33.      explicative and endearing descriptions found in the _p_e_r_l_d_i_a_g manpage.
  34.      Like the other pragmata, it affects the compilation phase of your program
  35.      rather than merely the execution phase.
  36.  
  37.      To use in your program as a pragma, merely invoke
  38.  
  39.          use diagnostics;
  40.  
  41.      at the start (or near the start) of your program.  (Note that this _d_o_e_s
  42.      enable perl's ----wwww flag.)  Your whole compilation will then be _s_u_b_j_e_c_t(ed
  43.      :-) to the enhanced diagnostics.  These still go out SSSSTTTTDDDDEEEERRRRRRRR.
  44.  
  45.      Due to the interaction between runtime and compiletime issues, and
  46.      because it's probably not a very good idea anyway, you may not use no
  47.      diagnostics to turn them off at compiletime.  However, you may control
  48.      there behaviour at runtime using the _d_i_s_a_b_l_e() and _e_n_a_b_l_e() methods to
  49.      turn them off and on respectively.
  50.  
  51.      The ----vvvveeeerrrrbbbboooosssseeee flag first prints out the the _p_e_r_l_d_i_a_g manpage introduction
  52.      before any other diagnostics.  The $diagnostics::PRETTY variable can
  53.      generate nicer escape sequences for pagers.
  54.  
  55.      TTTThhhheeee _s_p_l_a_i_n Program
  56.  
  57.      While apparently a whole nuther program, _s_p_l_a_i_n is actually nothing more
  58.      than a link to the (executable) _d_i_a_g_n_o_s_t_i_c_s._p_m module, as well as a link
  59.      to the _d_i_a_g_n_o_s_t_i_c_s._p_o_d documentation.  The ----vvvv flag is like the use
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SSSSPPPPLLLLAAAAIIIINNNN((((1111))))                                                            SSSSPPPPLLLLAAAAIIIINNNN((((1111))))
  71.  
  72.  
  73.  
  74.      diagnostics -verbose directive.  The ----pppp flag is like the
  75.      $diagnostics::PRETTY variable.  Since you're post-processing with _s_p_l_a_i_n,
  76.      there's no sense in being able to _e_n_a_b_l_e() or _d_i_s_a_b_l_e() processing.
  77.  
  78.      Output from _s_p_l_a_i_n is directed to SSSSTTTTDDDDOOOOUUUUTTTT, unlike the pragma.
  79.  
  80. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  81.      The following file is certain to trigger a few errors at both runtime and
  82.      compiletime:
  83.  
  84.          use diagnostics;
  85.          print NOWHERE "nothing\n";
  86.          print STDERR "\n\tThis message should be unadorned.\n";
  87.          warn "\tThis is a user warning";
  88.          print "\nDIAGNOSTIC TESTER: Please enter a <CR> here: ";
  89.          my $a, $b = scalar <STDIN>;
  90.          print "\n";
  91.          print $x/$y;
  92.  
  93.      If you prefer to run your program first and look at its problem
  94.      afterwards, do this:
  95.  
  96.          perl -w test.pl 2>test.out
  97.          ./splain < test.out
  98.  
  99.      Note that this is not in general possible in shells of more dubious
  100.      heritage, as the theoretical
  101.  
  102.          (perl -w test.pl >/dev/tty) >& test.out
  103.          ./splain < test.out
  104.  
  105.      Because you just moved the existing ssssttttddddoooouuuutttt to somewhere else.
  106.  
  107.      If you don't want to modify your source code, but still have on-the-fly
  108.      warnings, do this:
  109.  
  110.          exec 3>&1; perl -w test.pl 2>&1 1>&3 3>&- | splain 1>&2 3>&-
  111.  
  112.      Nifty, eh?
  113.  
  114.      If you want to control warnings on the fly, do something like this.  Make
  115.      sure you do the use first, or you won't be able to get at the _e_n_a_b_l_e() or
  116.      _d_i_s_a_b_l_e() methods.
  117.  
  118.          use diagnostics; # checks entire compilation phase
  119.              print "\ntime for 1st bogus diags: SQUAWKINGS\n";
  120.              print BOGUS1 'nada';
  121.              print "done with 1st bogus\n";
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SSSSPPPPLLLLAAAAIIIINNNN((((1111))))                                                            SSSSPPPPLLLLAAAAIIIINNNN((((1111))))
  137.  
  138.  
  139.  
  140.          disable diagnostics; # only turns off runtime warnings
  141.              print "\ntime for 2nd bogus: (squelched)\n";
  142.              print BOGUS2 'nada';
  143.              print "done with 2nd bogus\n";
  144.  
  145.          enable diagnostics; # turns back on runtime warnings
  146.              print "\ntime for 3rd bogus: SQUAWKINGS\n";
  147.              print BOGUS3 'nada';
  148.              print "done with 3rd bogus\n";
  149.  
  150.          disable diagnostics;
  151.              print "\ntime for 4th bogus: (squelched)\n";
  152.              print BOGUS4 'nada';
  153.              print "done with 4th bogus\n";
  154.  
  155.  
  156. IIIINNNNTTTTEEEERRRRNNNNAAAALLLLSSSS
  157.      Diagnostic messages derive from the _p_e_r_l_d_i_a_g._p_o_d file when available at
  158.      runtime.  Otherwise, they may be embedded in the file itself when the
  159.      splain package is built.   See the _M_a_k_e_f_i_l_e for details.
  160.  
  161.      If an extant $SIG{__WARN__} handler is discovered, it will continue to be
  162.      honored, but only after the _d_i_a_g_n_o_s_t_i_c_s::_s_p_l_a_i_n_t_h_i_s() function (the
  163.      module's $SIG{__WARN__} interceptor) has had its way with your warnings.
  164.  
  165.      There is a $diagnostics::DEBUG variable you may set if you're desperately
  166.      curious what sorts of things are being intercepted.
  167.  
  168.          BEGIN { $diagnostics::DEBUG = 1 }
  169.  
  170.  
  171. BBBBUUUUGGGGSSSS
  172.      Not being able to say "no diagnostics" is annoying, but may not be
  173.      insurmountable.
  174.  
  175.      The -pretty directive is called too late to affect matters.  You have to
  176.      do this instead, and _b_e_f_o_r_e you load the module.
  177.  
  178.          BEGIN { $diagnostics::PRETTY = 1 }
  179.  
  180.      I could start up faster by delaying compilation until it should be
  181.      needed, but this gets a "panic: top_level" when using the pragma form in
  182.      Perl 5.001e.
  183.  
  184.      While it's true that this documentation is somewhat subserious, if you
  185.      use a program named _s_p_l_a_i_n, you should expect a bit of whimsy.
  186.  
  187. AAAAUUUUTTTTHHHHOOOORRRR
  188.      Tom Christiansen <_t_c_h_r_i_s_t@_m_o_x._p_e_r_l._c_o_m>, 25 June 1995.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SSSSPPPPLLLLAAAAIIIINNNN((((1111))))                                                            SSSSPPPPLLLLAAAAIIIINNNN((((1111))))
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                                                                         PPPPaaaaggggeeee 4444
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.